package com.four.bmm.service;

import com.four.bmm.dao.IAdminDao;
import com.four.bmm.entity.Admin;
import com.four.bmm.entity.News;
import com.four.bmm.util.SqlSessionFactoryUtil;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

public class AdminService {
    SqlSession session = SqlSessionFactoryUtil.getSqlSession();
    IAdminDao adminDao = session.getMapper(IAdminDao.class);

    public List<Admin> findAllUser() {
        return adminDao.findAllUser();
    }

    /**
     * 管理员注册
     */
    public boolean registerAdmin(Admin admin) {
        boolean result = adminDao.registerAdmin(admin);
        session.commit();
        return result;
    }

    public Admin adminLogin(Admin admin) {
        return adminDao.adminLogin(admin);
    }

    /**
     * 管理员查看所有新闻
     * */
    public List<News> adminGetNewsNoPage() {
        NewsService newsService=new NewsService();
        return  newsService.GetAllNewsNoPage();
    }
}
